package com.cuijq.dubbo.core.health;

import com.cuijq.dubbo.core.server.NettyClient;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class NettyHealthIndicator implements HealthIndicator {
    private final NettyClient nettyClient;

    public NettyHealthIndicator(NettyClient nettyClient) {
        this.nettyClient = nettyClient;
    }

    @Override
    public Health health() {
        if (nettyClient.isRunning()) { // 假设NettyServer有状态检查方法
            return Health.up().build();
        } else {
            return Health.down().build();
        }
    }
}
